/**
 * @Author：ming
 * @Date：2023/9/29 12:31 PM
 * @Filename：Lc226
 */

/**
 * @author ming
 */
public class Lc226 {
    public TreeNode invertTree(TreeNode root) {
        if(root==null){
            return null;
        }

        if(root.left==null&&root.right==null){
            return root;
        }

        TreeNode p = root.left;
        root.left = invertTree(root.right);
        root.right = invertTree(p);

        return root;
    }
}
